package com.tx.producer;

import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.TextMessage;

/**
 * spring-队列生产者
 */
@Service
public class QueueProducer {

    @Autowired
    JmsTemplate jmsTemplate;

    public static void main(String[] args) {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
        QueueProducer queueProducer = (QueueProducer)ac.getBean("queueProducer");
//        System.out.println(queueProducer);

        queueProducer.jmsTemplate.send((session)->{
            TextMessage textMessage = session.createTextMessage("******spring发送的队列信息");
            return textMessage;
        });

        System.out.println("******spring queue推送完毕");
    }
}